package org.example.bootvue.validation;

import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;
import org.example.bootvue.anno.State;

public class StateValidation implements ConstraintValidator<State/*给哪个注解提供校验规则*/, String/*校验的数据类型*/> {
    @Override
    public boolean isValid(String s/*将来要校验的数据*/, ConstraintValidatorContext constraintValidatorContext) {
        //提供校验规则
        if (s == null)
        return false;
        if (s.equals("已发布")||s.equals("草稿"))
            return true;
        return false;
    }
}
